<?php
/**
 * @copyright	Copyright (c) 2014 nnc_slide. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */

// no direct access
defined('_JEXEC') or die;

/**
 * nnc_slide - nnc_slide Helper Class.
 *
 * @package		Joomla.Site
 * @subpakage	nnc_slide.nnc_slide
 */
class modnnc_slideHelper {
    
    /*
     * Date : 21/11/2014
     * Auhor: CN
     * Purpose: get data for slider
     * Table  : cn_content -> cn_categories
     * @pagram out: $data: array object : id,images
     */
    function getDataSlider()
    {
        $db = JFactory::getDbo();
        $query = "
            SELECT c.id,c.images 
                FROM cn_content as c 
                    WHERE c.catid = 13 AND c.state = 1    
        ";
        $db->setQuery($query);
        $data = $db->loadObjectList();
        return $data;
    }
    
    // get url host
    public static function getURL($url = '')
    {
        $uri = JURI::getInstance();
        $prefix = $uri->toString(array('host', 'port'));
        if ($url == '')
        {
          $scheme = $uri->getScheme();
        }
        else
        {
          $scheme = $url;
        }

        $host_uri = $scheme . '://' . $prefix;
        return $host_uri;
    }
}